package com.lbd.service;

import com.lbd.project.bean.TargetInfo;

import java.util.function.BinaryOperator;
import java.util.function.Predicate;

/**
 * Created by Yuanbo on 2016/11/11.
 */
public class LAMBDA {
    public static void testLambda() {
        Runnable runnable = () -> {
            System.out.println("hello");
        };
        Thread thread = new Thread(runnable);
        thread.start();

        BinaryOperator<Long> add = (x, y) -> x + y;
        System.out.println(add);
    }

    public static void main(String[] args) {
        testLambda();
        testLambdaFinal(); //lambda 里面引用的值,必须是常量
        testLambdaFX();//泛型

    }

    private static void testLambdaFX() {
        Predicate<Integer> atLeast = x -> x > 5;
        boolean test = atLeast.test(5);
        System.out.println(test);
    }

    private static void testLambdaFinal() {
        String str = "testLambda";
        Runnable runnable = () -> {
//            str = str+"11";
            System.out.println(str);
        };
    }
}
